package qinggui.mlz.smsservice.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import qinggui.mlz.smsservice.entity.SmsCrond;

import java.util.List;

@Mapper
public interface SmsCrondMapper {
    /**
     * 创建定时发送任务
     * @param smsCrond
     * @return Integer
     */
    @Insert("insert into sms_crond (phone, content, status, create_time, update_time, is_deleted) " +
            "values (#{smsCrond.phone}, #{smsCrond.content}, #{smsCrond.status}, #{smsCrond.createTime}, #{smsCrond.updateTime}, #{smsCrond.isDeleted})")
    Integer createCronSend(@Param("smsCrond") SmsCrond smsCrond);

    /**
     * 获取未发送的定时发送任务
     * @return List<SmsCrond>
     */
    @Select("select * from sms_crond where status = 0 and is_deleted=0")
    List<SmsCrond> listUnSendCronSend();

    /**
     * 更新定时发送任务
     * @param smsCrond
     * @return Integer
     */
    Integer updateById(@Param("smsCrond") SmsCrond smsCrond);

    /**
     *  批量更新定时发送任务
     * @param updateList 更新列表
     * @return Integer
     */
    Integer batchUpdate(@Param("updateList") List<SmsCrond> updateList);
}
